<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
     xmlns:h="http://java.sun.com/jsf/html" 
     xmlns:p="http://primefaces.prime.com.tr/ui" 
     xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:f="http://java.sun.com/jsf/core">  
   
    <h:head>
       <title>:.Medral Tecnologia Penha.:</title>
    </h:head>
    
    <h:body style="background-color: paleturquoise"> 
    
    <ui:include src="/paginas/menu.xhtml"/>   
        
    <p:growl id="avisos" showDetail="true" life="3000" />  

    <p:fieldset legend="CADASTRO DE FORNECEDORES:" toggleable="true">  
    <h:form> 
        
        <h:panelGrid columns="2">
            <h:outputText value="Data do Cadastro:"/>  
            <p:calendar value="#{FornecedorBean.fornecedor.dataCadastro}" maxlength="12" size="10"/> 
                
            <h:outputText value="Nome:" />  
            <p:inputText id="nome" value="#{FornecedorBean.fornecedor.nome}" maxlength="60" size="50"/>
        
            <h:outputText value="CNPJ:"/>
            <p:inputMask mask="99.999.999/9999-99" value="#{FornecedorBean.fornecedor.cnpj}" maxlength="12" size="20"/>
        
            <h:outputText value="Email:" />  
            <p:inputText id="email" value="#{FornecedorBean.fornecedor.email}" maxlength="40" size="35"/>
        </h:panelGrid>   

        <h:panelGrid columns="6">       
            <h:outputText value="Celular:"/>
            <p:inputMask mask="(99)9999-9999" value="#{FornecedorBean.fornecedor.telefone}" maxlength="12" size="12"/>
            
            <h:outputText value="Tel. Comercial:"/>
            <p:inputMask mask="(99)9999-9999" value="#{FornecedorBean.fornecedor.telefone}" maxlength="12" size="12"/>
            
            <h:outputText value="Tel. Fax:"/>
            <p:inputMask mask="(99)9999-9999" value="#{FornecedorBean.fornecedor.telefone}" maxlength="12" size="12"/>
        </h:panelGrid> 
        
        <h:panelGrid columns="4">
            <h:outputText value="Endereço:" />  
            <p:inputText id="endereco" value="#{FornecedorBean.fornecedor.endereco}" maxlength="46" size="46"/>
        
            <h:outputText value="Bairro:" />  
            <p:inputText id="bairro" value="#{FornecedorBean.fornecedor.bairro}" maxlength="20" size="10"/>
        </h:panelGrid>   
        
        <p:separator style="width: 100%; height: 3px" />  

        <p:commandButton value="CADASTRAR" actionListener="#{FornecedorBean.fornecedor.cadastrar}" type="submit" />
        <p:commandButton value="LIMPAR CAMPOS" actionListener="#{FornecedorBean.fornecedor.limpar}" type="reset" /> 
        
        </h:form>  
        </p:fieldset>  
    
    <p:fieldset legend="LISTA GERAL:" toggleable="true">  
   <h:form id="form">

                <p:growl id="msgs" />

                 <p:outputPanel id="books">
                    <p:dataTable id="booksTable" value="#{bookBean.books}" var="book">

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Data" />
                            </f:facet>
                            <h:outputText value="#{book.data}" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Nome" />
                            </f:facet>
                            <h:outputText value="#{book.nomeForn}" />
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                             <h:outputText value="CNPJ" />
                            </f:facet>
                            <h:outputText value="#{book.cnpj}" />
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Email" />
                            </f:facet>
                            <h:outputText value="#{book.email}" />
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Telefone" />
                            </f:facet>
                            <h:outputText value="#{book.telefone}" />
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Endereço" />
                            </f:facet>
                            <h:outputText value="#{book.endereco}" />
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Bairro" />
                            </f:facet>
                            <h:outputText value="#{book.bairro}" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Operação" />
                            </f:facet>
                            
                            <p:commandLink value="Excluir" update=":form:books" process=":form:books">
                                <p:collector value="#{book}"
                                             removeFrom="#{bookBean.books}" />
                            </p:commandLink>
                        </p:column>

                    </p:dataTable>
                </p:outputPanel>

            </h:form>  
        </p:fieldset>     

        <p:messages id="mensagens" showDetail="true" />  

    </h:body>  

 </html> 

 